<template>
    <div class="airContent" @click.stop>
        <div class="airBox" id="depBox">
            <div class="depBox-cont" id="depBox-cont">
                <div class='dep-item' v-for="key in depData" @click="addData(key)">
                    <div class="dep-itemC">
                        {{key.name}}-{{key.iT}}
                    </div>
                </div>
            </div>
            <scrollbar4 :das="scrollNode" :change="shos"></scrollbar4>
        </div>
    </div>
</template>
<script>

import scrollbar4 from '../component/scrollBarUltimate.vue';
let depData='';
export default {
    data(){
        return {
            opp:0,
            depData:'',
            scrollNode:{
                parent:"depBox",
                child:"depBox-cont",
                courseN:"course4",
                sliderN:"slider4",
                speed:60
            },
            shos:false,
            lastData:""
        }
    },
    watch:{
        select:function () {
            let arr=[];
            depData.forEach((val)=>{
                if(val.iT!=''&&val.iT!=undefined){
                    if(new RegExp(this.select.toUpperCase()).test(val.iT.toUpperCase())||new RegExp(this.select.toUpperCase()).test(val.name.toUpperCase())){
                        arr.push(val);
                    }
                }else if(new RegExp(this.select.toUpperCase()).test(val.iT.toUpperCase())||new RegExp(this.select.toUpperCase()).test(val.name.toUpperCase())){
                    if(new RegExp(this.select.toUpperCase()).test(val.name.toUpperCase())){
                        arr.push(val);
                    }
                }
            });
            this.depData=arr;
            this.shos=!this.shos;
        }
    },
    props:['select'],
    components:{
        scrollbar4:scrollbar4
    },
    mounted(){
        this.depData=JSON.parse(sessionStorage.getItem('department'));
        depData=JSON.parse(sessionStorage.getItem('department'));
    },
    methods:{
        addData:function (dep) {
            this.lastData=dep.name;
            this.$emit('message', dep);
            document.getElementById(this.scrollNode.child).style.top='0px';
        }
    }
}
</script>
<style scoped>
    .airContent{
        height: 250px !important;
    }
    .airBox{
        max-height:250px;
        min-height:0px;
        height:auto !important;
        overflow: hidden !important;
        position:relative;
    }
    .dep-item{
        height: 25px;
        width: 574px;
        color: white;
    }
    .dep-item:hover{
        background-color:#25406d;
        color: #be5428;
        cursor:pointer;
        transition: background .3s linear;
        background: -webkit-gradient(linear, 0% 0%, 0% 100%,from(#224b79), to(#263763));
        background: -moz-linear-gradient(top, #224b79, #263763);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#224b79', endColorstr='#263763');
    }
    .dep-itemC{
        height: 25px;
        line-height:25px;
        font-size:12px;
        display: inline-block;
        margin-left: 25px;
    }
    .depBox-title{
        height: 43px;
    }
    .depBox-cont{
        /*height:250px;*/
        background-color:#0f1e35;
        position: relative;
        top:0px;
        width: 100%;
    }
    .depBox-title>ul{
        margin: 0px;
        padding:0px;
        display:-webkit-box;
        display: -moz-box;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
    }
    .depBox-title>ul>li{
        margin: 0px;
        padding:0px;
        text-align:center;
        height:40px;
        border-bottom:3px solid transparent;
        flex:1;
        font-size:13px;
        line-height:40px;
        color:white;
    }
</style>